/*---- Inicio Borrado de Tablas ------*/

/*alter table Tbl_Empleados
   drop constraint Id_Tbl_Persona_Fk;

alter table Tbl_Registros_Laborales
   drop constraint Id_Tbl_Empleado_Fk;
   
alter table Tbl_Conductores
   drop constraint Id_Tbl_Empleado_Fk;

alter table Tbl_Vehiculos
   drop constraint Id_Tbl_Categoria_Fk;   
   
alter table Tbl_Conductores_Vehiculos
   drop constraint Id_Tbl_Empleado_Fk,
   drop constraint Id_Tbl_Vehiculo_Fk;   

alter table Tbl_Combustible_Vehiculos
   drop constraint Id_Tbl_Combustible_Fk,
   drop constraint Id_Tbl_Vehiculo_Fk;  

alter table Tbl_Viajes
   drop constraint Id_Tbl_Lugar_Origen_Fk,
   drop constraint Id_Tbl_Lugar_Destino_Fk;  
   
alter table Tbl_Peajes_Viajes
   drop constraint Id_Tbl_Peajes_Fk,
   drop constraint Id_Tbl_viajes_Fk;  
   
alter table Tbl_Costos_Peajes
   drop constraint Id_Tbl_Peajes_Fk,
   drop constraint Id_Tbl_Categoria_Fk;  
   
alter table Tbl_Reservas
   drop constraint Id_Solicitante_Fk;  

alter table Tbl_Avances_Reintegros
   drop constraint Id_Tbl_Reserva_Fk; */
   
DROP table Tbl_Personas CASCADE CONSTRAINTS;
DROP table Tbl_Empleados CASCADE CONSTRAINTS;
DROP table Tbl_Registros_Laborales CASCADE CONSTRAINTS;
DROP table Tbl_Conductores CASCADE CONSTRAINTS;
DROP table Tbl_Categorias CASCADE CONSTRAINTS;
DROP table Tbl_Vehiculos CASCADE CONSTRAINTS;
DROP table Tbl_Conductores_Vehiculos CASCADE CONSTRAINTS;
DROP table Tbl_Combustible CASCADE CONSTRAINTS;
DROP table Tbl_Combustible_Vehiculos CASCADE CONSTRAINTS;
DROP table Tbl_Lugares CASCADE CONSTRAINTS;
DROP table Tbl_Viajes CASCADE CONSTRAINTS;
DROP table Tbl_Peajes CASCADE CONSTRAINTS;
DROP table Tbl_Peajes_Viajes CASCADE CONSTRAINTS;
DROP table Tbl_Costos_Peajes CASCADE CONSTRAINTS;
DROP table Tbl_Reservas CASCADE CONSTRAINTS;
DROP table Tbl_Dependencias CASCADE CONSTRAINTS;
DROP table Tbl_Avances_Reintegros CASCADE CONSTRAINTS; 

/*---- Fin Borrado de Tablas ------*/

CREATE TABLE Tbl_Cargos (
CargoId Number(8) NOT NULL,
Nombre_Cargo  VARCHAR(30),
CONSTRAINT Tbl_Cargo_Pk PRIMARY KEY (CargoId)
);

CREATE SEQUENCE CargoId
START WITH 1
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER  "TRIG_INSERT_CARGO" 
BEFORE INSERT ON Tbl_Cargos 
FOR EACH ROW
BEGIN
SELECT CargoId.NEXTVAL INTO :NEW.CargoId FROM DUAL;
END;


CREATE TABLE Tbl_Cargos_Dependencias (
CargoId Number(8) NOT NULL,
DependenciaId Number(8) NOT NULL,
CONSTRAINT DependenciaId_Car_Dep_Fk  FOREIGN KEY (DependenciaId) REFERENCES Tbl_Dependencias(DependenciaId),
CONSTRAINT CargoId_Car_Dep_Fk  FOREIGN KEY (CargoId) REFERENCES Tbl_Cargos(CargoId),
CONSTRAINT Tbl_Cargos_Dependencias_Pk PRIMARY KEY (CargoId,DependenciaId)
);

CREATE SEQUENCE CargoId2
START WITH 1
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER  "TRIG_INSERT_CARGO_DEPENDENCIA" 
BEFORE INSERT ON Tbl_Cargos_Dependencias 
FOR EACH ROW
BEGIN
SELECT CargoId2.NEXTVAL INTO :NEW.CargoId FROM DUAL;
END;

CREATE TABLE Tbl_Telefonos (
TelefonoId Number(8) NOT NULL,
Numero NUMBER(20) NOT NULL,
Extension NUMBER(20),
Tipo VARCHAR(30),
CONSTRAINT Tbl_Persona_Pk PRIMARY KEY (TelefonoId)
);

CREATE SEQUENCE TelefonoId
START WITH 1
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER  "TRIG_INSERT_TEL" 
BEFORE INSERT ON Tbl_Telefonos
FOR EACH ROW
BEGIN
SELECT TelefonoId.NEXTVAL INTO :NEW.TelefonoId FROM DUAL;
END;

CREATE TABLE Tbl_Personas_Telefonos (
personaId NUMBER(8) NOT NULL,
TelefonoId Number(8) NOT NULL,
CONSTRAINT Telefonoid_Fk  FOREIGN KEY (personaId) REFERENCES Tbl_Personas(personaId)
CONSTRAINT Perdonaid_Fk  FOREIGN KEY (TelefonoId) REFERENCES Tbl_Telefonos(TelefonoId),
CONSTRAINT Tbl_Persona_Pk PRIMARY KEY (personaId,TelefonoId)
);
/*==============================================================
Table: Tbl_Personas
Descripcion: Tabla para el registro de informacion de todas 
las personas relacionadas a la aplicacion.                   
==============================================================*/  
CREATE TABLE Tbl_Personas (
personaId NUMBER(8) NOT NULL,
Nombres VARCHAR(30) NOT NULL,
Apellidos VARCHAR(30) NOT NULL,
Sexo CHARACTER (1) NOT NULL,
Direccion VARCHAR(25),
Correos VARCHAR(80),
Identificacion NUMBER(15) NOT NULL,
Tipo_Identificacion VARCHAR(20) NOT NULL,
CONSTRAINT Tbl_Persona_Pk PRIMARY KEY (personaId)
);
CREATE SEQUENCE personaId
START WITH 1
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER  "TRIG_INSERT_PER" 
BEFORE INSERT ON Tbl_Personas
FOR EACH ROW
BEGIN
SELECT personaId.NEXTVAL INTO :NEW.personaId FROM DUAL;
END;

/*==============================================================
Table: Tbl_Empleados
Descripcion: Tabla que Guarda la Informacion necesaria relacionada 
a los empleados de las division administrativa y de servicios.                   
==============================================================*/  
CREATE TABLE Tbl_Empleados (
empleadoId NUMBER(8) NOT NULL,
DependenciaId Number(8) NOT NULL,
Fecha_Inicio DATE NOT NULL,
Fecha_Fin DATE,
Responsable VARCHAR(50) NOT NULL,
CargoId Number(8) NOT NULL,
Descripcion VARCHAR(120),
Estado NUMBER NOT NULL,
CONSTRAINT Id_Tbl_Dependencias_Fk  FOREIGN KEY (DependenciaId) REFERENCES Tbl_Dependencias(DependenciaId),
CONSTRAINT Id_Tbl_Persona_Fk  FOREIGN KEY (empleadoId) REFERENCES Tbl_Personas(personaId),
CONSTRAINT Tbl_Empleados_Pk PRIMARY KEY (empleadoId)
);

/*==============================================================
Table: Tbl_Registros_Laborales
Descripcion: Tabla que hace referencia al registro de horas 
laborales que realizan los empleados, tabla opcional y alternativa
inicial para el manejo de lo relativo a las horas extras de 
los empleados                 
==============================================================*/ 
CREATE TABLE Tbl_Registros_Laborales (
registroLaboralId NUMBER(8) NOT NULL,
empleadoId NUMBER (8) NOT NULL,
Dia NUMBER (2) NOT NULL,
Mes NUMBER (2) NOT NULL,
Anio NUMBER (4) NOT NULL,
Hora_Inicio DATE NOT NULL,
Hora_Fin DATE NOT NULL,
Estado NUMBER NOT NULL,
CONSTRAINT Id_Tbl_Empleado_RL_Fk FOREIGN KEY (empleadoId) REFERENCES Tbl_Empleados(empleadoId),
CONSTRAINT Tbl_Tbl_Registros_Laborales_Pk PRIMARY KEY (registroLaboralId)
);
CREATE SEQUENCE registroLaboralId
START WITH 1
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER  "TRIG_INSERT_REGLAB" 
BEFORE INSERT ON Tbl_Registros_Laborales
FOR EACH ROW
BEGIN
SELECT registroLaboralId.NEXTVAL INTO :NEW.registroLaboralId FROM DUAL;
END;

/*==============================================================
Table: Tbl_Categorias
Descripcion: Tabla que guarda la informacion de las categorias 
en las que se dividen los diferentes vehiculos en los peajes.               
==============================================================*/ 
CREATE TABLE Tbl_Categorias(
categoriaId NUMBER(8) NOT NULL,
Nombre VARCHAR(20) NOT NULL,
Descripcion VARCHAR(20) NOT NULL,
CONSTRAINT Tbl_Categorias_Pk PRIMARY KEY (categoriaId)
);
CREATE SEQUENCE categoriaId
START WITH 1
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER  "TRIG_INSERT_CAT" 
BEFORE INSERT ON TBL_CATEGORIAS
FOR EACH ROW
BEGIN
SELECT categoriaId.NEXTVAL INTO :NEW.CATEGORIAID FROM DUAL;
END;

/*==============================================================
Table: Tbl_Vehiculos
Descripcion: Tabla que guarda la informacion de las categorias 
en las que se dividen los diferentes vehiculos en los peajes.               
==============================================================*/ 
CREATE TABLE Tbl_Vehiculos(
vehiculoId NUMBER(8) NOT NULL,
categoriaId NUMBER(8) NOT NULL,
Placa VARCHAR(15) NOT NULL,
Marca VARCHAR(30) NOT NULL,
Modelo NUMBER(4) NOT NULL,
Prototipo VARCHAR(20) NOT NULL,
Capacidad_Max NUMBER NOT NULL,
Peso_Max FLOAT,
Dimensiones_Carga VARCHAR(30), 
Estado NUMBER NOT NULL,
CONSTRAINT Id_Tbl_Categoria_TV_Fk FOREIGN KEY (categoriaId) REFERENCES Tbl_Categorias(categoriaId),
CONSTRAINT Tbl_Vehiculos_Pk PRIMARY KEY (vehiculoId)
);
CREATE SEQUENCE vehiculoId
START WITH 1
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER  "TRIG_INSERT_VEH" 
BEFORE INSERT ON TBL_VEHICULOS
FOR EACH ROW
BEGIN
SELECT vehiculoId.NEXTVAL INTO :NEW.VEHICULOID FROM DUAL;
END;
/*==============================================================
Table: Tbl_Conductores_Vehiculos
Descripcion: Tabla que relaciona el conductor con el vehiculo 
que tiene asignado en un rango de tiempo.             
==============================================================*/ 
CREATE TABLE Tbl_Conductores_Vehiculos(
conductorVehiculoId NUMBER(8) NOT NULL,
conductorId NUMBER(8) NOT NULL,
vehiculoId NUMBER(8) NOT NULL,
Fecha_Inicio DATE,
Fecha_Final Date,
Estado NUMBER NOT NULL,
CONSTRAINT Id_Tbl_Conductor_TCV_Fk FOREIGN KEY (conductorId) REFERENCES Tbl_Conductores(conductorId),
CONSTRAINT Id_Tbl_Vehiculo_TCV_Fk FOREIGN KEY (vehiculoId) REFERENCES Tbl_Vehiculos(vehiculoId),
CONSTRAINT Tbl_Vehiculo_Pk PRIMARY KEY (conductorVehiculoId)
);

CREATE SEQUENCE conductorVehiculoId
START WITH 1
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER  "TRIG_INSERT_CONVEH" 
BEFORE INSERT ON Tbl_Conductores_Vehiculos
FOR EACH ROW
BEGIN
SELECT conductorVehiculoId.NEXTVAL INTO :NEW.conductorVehiculoId FROM DUAL;
END;

/*==============================================================
Table: Tbl_Combustible
Descripcion: Tabla empleada para registrar en la base de datos los 
diferentes combustibles con los que puede funcionar los vehiculos.             
==============================================================*/ 
CREATE TABLE Tbl_Combustibles(
combustibleId NUMBER(8) NOT NULL,
Nombre_Combustible VARCHAR(25) NOT NULL,
CONSTRAINT Tbl_Combustible_Pk PRIMARY KEY (combustibleId)
);
CREATE SEQUENCE combustibleId
START WITH 1
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER  "TRIG_INSERT_COMBUSTIBLE" 
BEFORE INSERT ON TBL_COMBUSTIBLES
FOR EACH ROW
BEGIN
SELECT combustibleId.NEXTVAL INTO :NEW.COMBUSTILEID FROM DUAL;
END;
/*==============================================================
Table: Tbl_Combustible_Vehiculos
Descripcion: Tabla que relaciona los diferentes vehiculos con 
los combustibles con los que funciona el vehiculo.              
==============================================================*/ 
CREATE TABLE Tbl_Combustible_Vehiculos(
combustibleVehiculoId NUMBER(8) NOT NULL,
vehiculoId NUMBER(8) NOT NULL,
combustibleId NUMBER(8) NOT NULL,
Capacidad_Max FLOAT,
DescripcionVARCHAR(80),
CONSTRAINT Id_Tbl_Vehiculo_TComV_Fk FOREIGN KEY (vehiculoId) REFERENCES Tbl_Vehiculos(vehiculoId),
CONSTRAINT Id_Tbl_Combustible_TComV_Fk FOREIGN KEY (combustibleId) REFERENCES Tbl_Combustibles(combustibleId),
CONSTRAINT Tbl_Combustible_Vehiculos_Pk PRIMARY KEY (combustibleVehiculoId)
);
CREATE SEQUENCE combustibleVehiculoId
START WITH 1
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER  "TRIG_INSERT_COMBUS_VEH" 
BEFORE INSERT ON Tbl_Combustible_Vehiculos
FOR EACH ROW
BEGIN
SELECT combustibleVehiculoId.NEXTVAL INTO :NEW.combustibleVehiculoId FROM DUAL;
END;
/*==============================================================
Table: Tbl_Lugares
Descripcion: Tabla que registra la informacion de los distintos 
lugares bien sean de origen o destino.              
==============================================================*/ 
CREATE TABLE Tbl_Lugares(
lugarId NUMBER(8) NOT NULL,
Lugar VARCHAR(100) NOT NULL,
Municipio VARCHAR(30) NOT NULL,
Departamento VARCHAR(30) NOT NULL,
CONSTRAINT Tbl_Lugares_Pk PRIMARY KEY (lugarId)
);
CREATE SEQUENCE lugarId
START WITH 1
INCREMENT BY 1;
CREATE OR REPLACE TRIGGER  "TRIG_INSERT_LUGARES" 
BEFORE INSERT ON Tbl_Lugares
FOR EACH ROW
BEGIN
SELECT lugarId.NEXTVAL INTO :NEW.lugarId FROM DUAL;
END;
/*==============================================================
Table: Tbl_Viajes
Descripcion: Tabla que guarda la informacion relacionada con 
los viajes de los servicios de transporte. 
==============================================================*/ 
CREATE TABLE Tbl_Viajes(
viajeId NUMBER(8) NOT NULL,
lugarOrigenId NUMBER(8) NOT NULL,
lugarDestinoId NUMBER(8) NOT NULL,
Ruta VARCHAR(50) NOT NULL,
Distancia  FLOAT NOT NULL,
CONSTRAINT Id_Tbl_Lugar_Origen_TVjes_Fk FOREIGN KEY (lugarOrigenId) REFERENCES Tbl_Lugares(lugarId),
CONSTRAINT Id_Tbl_Lugar_Destino_TVjes_Fk FOREIGN KEY (lugarOrigenId) REFERENCES Tbl_Lugares(lugarId),
CONSTRAINT Tbl_Viajes_Pk PRIMARY KEY (viajeId)
);
CREATE SEQUENCE viajeId
START WITH 1
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER  "TRIG_INSERT_VIAJE" 
BEFORE INSERT ON Tbl_Viajes
FOR EACH ROW
BEGIN
SELECT viajeId.NEXTVAL INTO :NEW.viajeId FROM DUAL;
END;
/*==============================================================
Table: Tbl_Peajes
Descripcion: Tabla que guarda la informacion de los diferentes 
peajes existentes. 
==============================================================*/ 
CREATE TABLE Tbl_Peajes(
peajeId NUMBER(8) NOT NULL,
Nombre_Peaje VARCHAR(30) NOT NULL,
Municipio VARCHAR(30) NOT NULL,
Departamento VARCHAR(30) NOT NULL,
CONSTRAINT Tbl_Peajes_Pk PRIMARY KEY (peajeId)
);
CREATE SEQUENCE peajeId
START WITH 1
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER  "TRIG_INSERT_PEAJE" 
BEFORE INSERT ON Tbl_Peajes
FOR EACH ROW
BEGIN
SELECT peajeId.NEXTVAL INTO :NEW.peajeId FROM DUAL;
END;
/*==============================================================
Table: Tbl_Peajes
Descripcion: Tabla que relaciona los peajes que existen en un 
viaje desde el punto de origen hasta el punto de destino.
==============================================================*/ 
CREATE TABLE Tbl_Peajes_Viajes(
peajeId NUMBER(8) NOT NULL,
viajeId NUMBER(8) NOT NULL,
CONSTRAINT Id_Tbl_Peajes_TPV_Fk FOREIGN KEY (peajeId) REFERENCES Tbl_Peajes(peajeId),
CONSTRAINT Id_Tbl_viajes_TPV_Fk FOREIGN KEY (viajeId) REFERENCES Tbl_Viajes(viajeId),
CONSTRAINT Tbl_Peajes_Viajes_Pk PRIMARY KEY (peajeId,viajeId)
);

/*==============================================================
Table: Tbl_Costos_Peajes
Descripcion: Tabla que guarda los distintos pejes pagados.
==============================================================*/ 
CREATE TABLE Tbl_Costos_Peajes(
costoPeajeId NUMBER(8) NOT NULL,
peajeId NUMBER(8) NOT NULL,
categoriaId NUMBER(8) NOT NULL,
Costo FLOAT NOT NULL,
Fecha_Inicio DATE NOT NULL,
Fecha_Fin DATE NOT NULL,
Estado NUMBER NOT NULL,
CONSTRAINT Id_Tbl_Peajes_TCP_Fk FOREIGN KEY (peajeId) REFERENCES Tbl_Peajes(peajeId),
CONSTRAINT Id_Tbl_Categoria_TCP_Fk FOREIGN KEY (categoriaId) REFERENCES Tbl_Categorias(categoriaId),
CONSTRAINT Tbl_Costos_Peajes_Pk PRIMARY KEY (costoPeajeId)
);
CREATE SEQUENCE costoPeajeId
START WITH 1
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER  "TRIG_INSERT_COSTO_PEAJE" 
BEFORE INSERT ON Tbl_Costos_Peajes
FOR EACH ROW
BEGIN
SELECT costoPeajeId.NEXTVAL INTO :NEW.costoPeajeId FROM DUAL;
END;

/*==============================================================
Table: Tbl_Costos_Peajes
Descripcion: Tabla que guarda la informacion sobre las reservas 
de los vehiculos, es decir guarda la informacion de las reservas 
de vehiculos realizadas para el servicio de transporte.
==============================================================*/ 
CREATE TABLE Tbl_Reservas(
reservaId NUMBER(8) NOT NULL,
solicitanteId NUMBER(8) NOT NULL,
conductorId NUMBER(8),
vehiculoId NUMBER(8),
Codigo NUMBER(25) NOT NULL,
Radicado VARCHAR(100) NOT NULL,
Fecha_Radicado TIMESTAMP  NOT NULL,
Fecha_Registro TIMESTAMP  NOT NULL,
Fecha_Inicio DATE NOT NULL,
Fecha_Fin TIMESTAMP NOT NULL,
Hora_Encuentro DATE NOT NULL,
Numero_Personas NUMBER(8),
Dimensiones_Necesarias VARCHAR(30),
Peso FLOAT,
Estado NUMBER NOT NULL,
Observaciones VARCHAR(200),
CONSTRAINT Id_Solicitante_TR_Fk FOREIGN KEY (solicitanteId) REFERENCES Tbl_Personas(personaId),
CONSTRAINT Id_Tbl_Conductor_TR_Fk FOREIGN KEY (conductorId) REFERENCES Tbl_Conductores(conductorId),
CONSTRAINT Id_Tbl_Vehiculo_TR_Fk FOREIGN KEY (vehiculoId) REFERENCES Tbl_Vehiculos(vehiculoId),
CONSTRAINT Tbl_Reservas_Pk PRIMARY KEY (reservaId)
);
CREATE SEQUENCE reservaId
START WITH 1
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER  "TRIG_INSERT_RESEERVA" 
BEFORE INSERT ON Tbl_Reservas
FOR EACH ROW
BEGIN
SELECT reservaId.NEXTVAL INTO :NEW.reservaId FROM DUAL;
END;
/*==============================================================
Table: Tbl_ReservasViajes
Descripcion: guarda la informacion de los destinos que se 
consultaran en una reserva o servicio de transporte
==============================================================*/ 
CREATE TABLE Tbl_ReservasViajes(
reservaViajeId NUMBER(8) NOT NULL,
reservaId NUMBER(8) NOT NULL,
viajeId NUMBER(8) NOT NULL,
orden NUMBER NOT NULL,
CONSTRAINT Id_Reserva_TR_Fk FOREIGN KEY (reservaId) REFERENCES Tbl_Reservas(reservaId),
CONSTRAINT Id_Viaje_TR_Fk FOREIGN KEY (viajeId) REFERENCES Tbl_Viajes(viajeId),
CONSTRAINT Tbl_ReservasViajes_Pk PRIMARY KEY (reservaViajeId)
);
CREATE SEQUENCE reservaViajeId
START WITH 1
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER  "TRIG_INSERT_RESER_VIAJE" 
BEFORE INSERT ON Tbl_ReservasViajes
FOR EACH ROW
BEGIN
SELECT reservaViajeId.NEXTVAL INTO :NEW.reservaViajeId FROM DUAL;
END;
/*==============================================================
Table: Tbl_Dependencias
Descripcion: Tabla que guardas las dependencias a las que se 
les carga los valores de los servicios de tranporte.
==============================================================*/ 
CREATE TABLE Tbl_Dependencias(
dependenciaId NUMBER(8) NOT NULL,
Nombre_Dependencia VARCHAR(30) NOT NULL,
CONSTRAINT Tbl_Dependencias_Pk PRIMARY KEY (dependenciaId)
);
CREATE SEQUENCE dependenciaId
START WITH 1
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER  "TRIG_INSERT_DEPENDENCIA" 
BEFORE INSERT ON Tbl_Dependencias
FOR EACH ROW
BEGIN
SELECT dependenciaId.NEXTVAL INTO :NEW.dependenciaId FROM DUAL;
END;

/*==============================================================
Table: Tbl_Avances_Reintegros
Descripcion: Tabla que guarda la informacion de los avances y 
los reintegros generados por una reserva.
==============================================================*/ 
CREATE TABLE Tbl_Avances_Reintegros(
avanceReintegroId NUMBER(8) NOT NULL,
reservaId NUMBER(8) NOT NULL,
personaId NUMBER(8),
dependenciaId NUMBER(8),
Codigo NUMBER(25) NOT NULL,
Porcentaje FLOAT,
Tipo VARCHAR(20) NOT NULL,
Observaciones VARCHAR(200)NOT NULL,
CONSTRAINT Id_Tbl_Reserva_TAR_Fk FOREIGN KEY (reservaId) REFERENCES Tbl_Reservas(reservaId),
CONSTRAINT Id_Tbl_Persona_TAR_Fk FOREIGN KEY (personaId) REFERENCES Tbl_Personas(personaId),
CONSTRAINT Id_Tbl_Dependencia_TAR_Fk FOREIGN KEY (dependenciaId) REFERENCES Tbl_Dependencias(dependenciaId),
CONSTRAINT Tbl_Avances_Reintegros_Pk PRIMARY KEY (avanceReintegroId)
);
CREATE SEQUENCE avanceReintegroId
START WITH 1
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER  "TRIG_INSERT_AVAN_REIN" 
BEFORE INSERT ON Tbl_Avances_Reintegros
FOR EACH ROW
BEGIN
SELECT avanceReintegroId.NEXTVAL INTO :NEW.avanceReintegroId FROM DUAL;
END;


